package com.kongxx.struts2study.jfreechart.web.action;

import com.opensymphony.xwork2.ActionSupport;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;

public class MyStackBarChart1Action extends ActionSupport {

	private JFreeChart chart;

	public String execute() throws Exception {
		DefaultCategoryDataset dataset = new DefaultCategoryDataset();
		dataset.addValue(10.0D, "Series 1", "Jan");
		dataset.addValue(12.0D, "Series 1", "Feb");
		dataset.addValue(13.0D, "Series 1", "Mar");
		dataset.addValue(4.0D, "Series 2", "Jan");
		dataset.addValue(3.0D, "Series 2", "Feb");
		dataset.addValue(2.0D, "Series 2", "Mar");
		dataset.addValue(2.0D, "Series 3", "Jan");
		dataset.addValue(3.0D, "Series 3", "Feb");
		dataset.addValue(2.0D, "Series 3", "Mar");
		dataset.addValue(2.0D, "Series 4", "Jan");
		dataset.addValue(3.0D, "Series 4", "Feb");
		dataset.addValue(4.0D, "Series 4", "Mar");
		//chart = ChartFactory.createStackedBarChart("Stack Bar Chart Demo", "Category", "Value", dataset, PlotOrientation.VERTICAL, true, false, false);
		//chart = ChartFactory.createStackedBarChart("Stack Bar Chart Demo", "Category", "Value", dataset, PlotOrientation.HORIZONTAL, true, false, false);
		chart = ChartFactory.createStackedBarChart3D("Stack Bar Chart Demo", "Category", "Value", dataset, PlotOrientation.VERTICAL, true, false, false);
		//chart = ChartFactory.createStackedBarChart3D("Stack Bar Chart Demo", "Category", "Value", dataset, PlotOrientation.HORIZONTAL, true, false, false);
		return SUCCESS;
	}

	public JFreeChart getChart() {
		return chart;
	}

	public void setChart(JFreeChart chart) {
		this.chart = chart;
	}
}